﻿using Newtonsoft.Json;
using System;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
//using ABB.Robotics.RobotStudio;
//using ABB.Robotics.RobotStudio.Stations;
//using ABB.Robotics.Controllers;
//using ABB.Robotics.Controllers.RapidDomain;


namespace Deepseek_Robot
{
    public partial class MainWindow : Window
    {
        private const string DeepseekApiUrl = "https://api.deepseek.com/v1/chat/completions";
        private const string ApiKey = "sk-06875ba1342b4cb3a06f344a196843ce";

        public MainWindow()
        {
            InitializeComponent();
            this.DataContext = new MainWindowViewModel();
        }

        private async void SendCodeButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //string userInput = userInputTextBox.Text;
                //if (string.IsNullOrEmpty(userInput))
                //{
                //    MessageBox.Show("请输入需求。");
                //    return;
                //}
                //// 调用 DeepSeek API 生成代码
                //string generatedCode = await CallDoubaoApi(userInput);
                //generatedCodeTextBox.Text = generatedCode;
                //下发代码到机器人
                //await SendCodeToRobot(generatedCode);
                //MessageBox.Show("程序下发成功。");
            }
            catch (Exception ex)
            {
                MessageBox.Show($"发生错误: {ex.Message}");
            }
        }

        private void ListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            if (DataContext is MainWindowViewModel viewModel && e.AddedItems.Count > 0)
            {
                string selectedItem = e.AddedItems[0] as string;
                viewModel.NavigateTo(selectedItem);
            }
        }

    }
}